/*
 * @Description:: 请补充填写
 * @Version: 1.0
 * @Author: smallWhite
 * @Date: 2022-10-18 14:05:31
 * @LastEditors: smallWhite
 * @LastEditTime: 2023-08-13 11:18:26
 * @FilePath: /siana_admin/src/router/index.js
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
import { Layout } from '@/layouts/index'
import RouterViewLayout from '@/layouts/RouterViewLayout.vue'
Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}

export const routes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    meta: {
      title: '登录'
    },
    component: () => import('@/views/login'),
    hidden: true
  },
  {
    path: '/white',
    name: 'white',
    meta: {
      title: '登录'
    },
    component: () => import('@/views/white/white.vue'),
    hidden: true
  },
  {
    path: '/',
    name: 'index',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '',
        name: 'index',
        component: () => import('@/views/index/work-place'),
        meta: {
          title: '首页',
          icon: 'el-icon-s-home',
          cacheable: true
        }
      },
      {
        path: 'user',
        name: 'user',
        component: () => import('@/views/user/index'),
        meta: {
          icon: 'el-icon-s-custom',
          title: '用户管理',
          cacheable: false
        }
      },
      {
        path: 'role',
        name: 'role',
        component: () => import('@/views/role_management/index'),
        meta: {
          icon: 'el-icon-s-check',
          title: '角色管理',
          cacheable: false
        }
      },
      {
        path: 'notice',
        name: 'notice',
        component: () => import('@/views/notice/index'),
        meta: {
          icon: 'el-icon-s-comment',
          title: '公告管理',
          cacheable: false
        }
      },
      {
        path: 'product',
        name: 'product',
        component: () => import('@/views/product/index'),
        meta: {
          icon: 'el-icon-suitcase',
          title: '商品管理',
          cacheable: false
        }
      },
      {
        path: 'order',
        name: 'order',
        component: () => import('@/views/order/index'),
        meta: {
          icon: 'el-icon-document-remove',
          title: '订单管理',
          cacheable: false
        }
      },
      {
        path: 'gptkey',
        name: 'gptkey',
        component: () => import('@/views/gpt_key/index'),
        meta: {
          icon: 'el-icon-thumb',
          title: 'GPTKEY',
          cacheable: false
        }
      },
      {
        path: 'cardpin',
        name: 'cardpin',
        component: () => import('@/views/card_pin/index'),
        meta: {
          icon: 'el-icon-postcard',
          title: '卡密管理',
          cacheable: false
        }
      },
      {
        path: 'mail',
        name: 'mail',
        component: () => import('@/views/email/index'),
        meta: {
          icon: 'el-icon-message',
          title: '邮箱管理',
          cacheable: false
        }
      },
      {
        path: 'mjdjourney',
        name: 'mjdjourney',
        component: () => import('@/views/mjdjourney/index'),
        meta: {
          icon: 'el-icon-message',
          title: 'Mjdjourney管理',
          cacheable: false
        }
      },
      {
        path: 'stableDiffusion',
        name: 'stableDiffusion',
        meta: {
          icon: 'el-icon-cpu',
          title: 'S D 设置',
          cacheable: false
        },
        component: RouterViewLayout,
        children: [
          {
            path: '/stableDiffusion/model',
            name: 'sdModel',
            component: () => import('@/views/stableDiffusion/sdModel/index'),
            meta: {
              icon: 'el-icon-box',
              title: '模型设置',
              cacheable: false
            }
          },
          {
            path: '/stableDiffusion/lora',
            name: 'sdLora',
            component: () => import('@/views/stableDiffusion/sdLora/index'),
            meta: {
              icon: 'el-icon-box',
              title: 'Lora设置',
              cacheable: false
            }
          }
        ]
      },
      {
        path: 'system',
        name: 'system',
        meta: {
          icon: 'el-icon-s-tools',
          title: '系统配置',
          cacheable: false
        },
        component: RouterViewLayout,
        children: [
          {
            path: '/system/index',
            name: 'platform',
            component: () => import('@/views/system/platform/index'),
            meta: {
              icon: 'el-icon-box',
              title: '平台设置',
              cacheable: false
            }
          },
          {
            path: '/system/keyconfig',
            name: 'gpt',
            component: () => import('@/views/system/keyconfig/index'),
            meta: {
              icon: 'el-icon-box',
              title: 'key消耗配置',
              cacheable: false
            }
          },
          {
            path: '/system/gpt',
            name: 'gpt',
            component: () => import('@/views/system/gpt/index'),
            meta: {
              icon: 'el-icon-box',
              title: 'GPT设置',
              cacheable: false
            }
          },
           {
            path: '/system/stablediffusion',
            name: 'stablediffusion',
            component: () => import('@/views/system/stablediffusion/index'),
            meta: {
              icon: 'el-icon-picture-outline-round',
              title: 'StableDiffusion配置',
              cacheable: false
            }
          },
          // {
          //   path: '/system/midjourney',
          //   name: 'midjourney',
          //   component: () => import('@/views/system/midjourney/index'),
          //   meta: {
          //     icon: 'el-icon-postcard',
          //     title: 'Midjourney配置',
          //     cacheable: false
          //   }
          // }
          {
            path: '/system/flagstudio',
            name: 'flagstudio',
            component: () => import('@/views/system/flagstudio/index'),
            meta: {
              icon: 'el-icon-tickets',
              title: 'FlagStudio配置',
              cacheable: false
            }
          }, {
            path: '/system/baidu',
            name: 'baidu',
            component: () => import('@/views/system/baidu/index'),
            meta: {
              icon: 'el-icon-set-up',
              title: '百度配置',
              cacheable: false
            }
          }, {
            path: '/system/agent',
            name: 'agent',
            component: () => import('@/views/system/agent/index'),
            meta: {
              icon: 'el-icon-connection',
              title: '代理配置',
              cacheable: false
            }
          },
          {
            path: '/system/bing',
            name: 'bing',
            component: () => import('@/views/system/bing/index'),
            meta: {
              icon: 'el-icon-discount',
              title: 'Bing配置',
              cacheable: false
            }
          },
          {
            path: '/system/pay',
            name: 'pay',
            component: () => import('@/views/system/pay/index'),
            meta: {
              icon: 'el-icon-money',
              title: '支付配置',
              cacheable: false
            }
          },
          {
            path: '/system/client',
            name: 'client',
            component: () => import('@/views/system/client/index'),
            meta: {
              icon: 'el-icon-monitor',
              title: '客户端配置',
              cacheable: false
            }
          },
          {
            path: '/system/oss',
            name: 'client',
            component: () => import('@/views/system/oss/index'),
            meta: {
              icon: 'el-icon-monitor',
              title: '阿里OSS配置',
              cacheable: false
            }
          }

        ]
      },
      {
        path: 'log',
        name: 'log',
        component: () => import('@/views/log/index'),
        meta: {
          icon: 'el-icon-document',
          title: '操作日志',
          cacheable: false
        }
      }
    ]
  }
]

const createRouter = () => new VueRouter({
  mode: 'hash',
  scrollBehavior: () => ({ y: 0 }),
  routes
})

const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router
